Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix edge case in truncate function allowing too long slugs #74

Merged
merged 7 commits into from
Sep 30, 2022

Conversation

Redlinkk
Copy link
Contributor

Fixes #72

I'm not using operations on strings to avoid unnecessary allocations.
I've added a test case for the fixed issue.

@codecov
Copy link

codecov bot commented Aug 23, 2022

Codecov Report

Merging #74 (c05c02d) into master (452645f) will not change coverage.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##            master       #74   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines          150       142    -8     
=========================================
- Hits           150       142    -8     
Impacted Files Coverage Δ
slug.go 100.00% <100.00%> (ø)

@matrixik matrixik added the bug label Sep 27, 2022
@matrixik
Copy link
Member

Hello, sorry it took me so long to review it (burn out issues).

I improved tests to have more edge cases like this and rebased with master branch.
Looks like when fixing this problem you introduced another one: now it's cutting word that should not be cut.

Thank you for catching this. I will wait with releasing new version until this is merged.

@matrixik
Copy link
Member

--- FAIL: TestSlugMakeSmartTruncate (0.00s)
    slug_test.go:327: 4. MaxLength = 16; Make("Dobroslaw Zybort") = "dobroslaw"; want "dobroslaw-zybort"
    slug_test.go:327: 13. MaxLength = 6; Make("abc-de") = "abc"; want "abc-de"
    slug_test.go:327: 15. MaxLength = 6; Make("abc-de-fg") = "abc"; want "abc-de"
    slug_test.go:327: 18. MaxLength = 9; Make("abc-de-fg") = "abc-de"; want "abc-de-fg"
FAIL

@matrixik matrixik merged commit 6732d2a into gosimple:master Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Slug length can be MaxLength+1
2 participants